#!/bin/bash
#filename:opration.sh
#menu list
menu(){
	echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
	echo "1.add operation"
	echo "2.minus operation"
	echo "3.multiplication operation"
	echo "4.division operation"
	echo "5.compare number"
	echo "6.exit"
	echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
}
#1.add operation
add(){
	read -p "please input two numbers:" num1 num2
	echo "scale=4;${num1}+${num2}" |bc
	
} 
#2.minus operation
minus(){
	read -p "please input two numbers:" num3 num4
	echo "scale=4;${num3}-${num4}" |bc
}
#3.multiplication operation
multiplication(){
	read -p "please input two numbers:" num5 num6
	echo "scale=4;${num5}*${num6}" |bc
}
#4.division operation
division(){
	read -p "please input two nunbers:" num7 num8
	echo "scale=4;${num7}/${num8}" |bc
}
#5.compare numbers
compare(){
	read -p "please input two nunbers:" num9 num0
	if echo "${num9}-${num0}" |bc |grep "^0";then
		echo "${num9}==${num0}"
	elif echo "${num9}-${num0}" |bc |grep "^-";then
		echo "${num9}<${num0}"
	else
		echo "${num9}>${num0}"
	fi
}
#main function
main(){
	while :
	do	
	clear
	menu
	read -p "please input you option:" y_option
	case $y_option in
	1)
		add
		;;
	2)
		minus
		;;
	3)
		multiplication
		;;
	4)
		division
		;;
	5)
		compare
		;;
	6)
		exit
		;;
	*)
		exit
		;;
	esac
	read -p "Please enter Enter key to continue"	
	done	
}
main
